<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of polyfit2</title>
  <meta name="keywords" content="polyfit2">
  <meta name="description" content="POLYFIT2 polynomial approximation of a curve">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="#">imael</a> &gt; <a href="#">geom2d</a> &gt; polyfit2.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for .\imael\geom2d&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>polyfit2
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>POLYFIT2 polynomial approximation of a curve</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function coef = polyfit2(varargin) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment">POLYFIT2 polynomial approximation of a curve


   usage :
   P = POLYFIT2(X, Y, N) finds the coefficients of a polynomial P(X) of
   degree N that fits the data, P(X(I))~=Y(I), in a least-squares sense.

   P = POLYFIT2(Y, N) use default equal spacing between all values of Y
   array.

   P = POLYFIT2(..., COND) specify end conditions for interpolated
   polynom. COND is [M*1] array of values, M(0) is value of interpolated
   polynom for X(1), M(2) is value of first derivative at first point, and
   so on for each derivative degree of X.
   If COND is [M*2] array, first column gives conditions for first point,
   and second column gives conditions for second point.
   
   P = POLYFIT2(..., COND1, COND2) 
   where COND1 and COND2 are column arrays, specify different end
   condition for each limit of the polynom domain.
   
   Example
   % defines a basis and a function to interpolate
   N = 50;                         % 50 points
   x = linspace(0, pi, N);         % basis range from 0 to PI
   y = cos(x)+randn(1,N)*.2;       % cosine plus gaussian noise
   figure; plot(x, y, '+');        % display result
   % Fit a degree 3 polynom, imposing to pass through end points [0 1] and
   % [PI -1]:
   p1 = polyfit2(x, y, 3, [1], [-1]);
   % Fit a degree 3 polynom, imposing to pass through end points [0 1] and
   % [PI -1], and imposing first derivative equals to zero at end points:
   p2 = polyfit2(x, y, 3, [1;0], [-1;0]);
   % display the different approximations
   hold on;
   plot(x, polyval(p1, x), 'g');
   plot(x, polyval(p2, x), 'r');


   See also  :
   polyfit (matlab)

   -----

   author : David Legland
   INRA - TPV URPOI - BIA IMASTE
   created the 30/04/2004.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
<!-- crossreference -->



<hr><address>Generated on Fri 05-Feb-2010 11:20:41 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>